#ifndef CWORLDENGINE_H_
#define CWORLDENGINE_H_

#include "SGD Wrappers/CSGD_TextureManager.h"
#include "Messaging/CEventSystem.h"

#include "CGame.h"
#include "CBase.h"
#include "CCamera.h"

#include "CGamePlayState.h"

#include <vector>
#include <string>
#include <fstream>
#include <stdio.h>

using namespace std;

enum COLLISION_TYPE { NONE, SOLID, WATER, EVENT };
enum OBJECT_TYPE { OBJ_NONE, ENEMYSPAWN, SAVEPOINT, WEAPON, MAXHEALTHUP };

class CWorldEngine
{
private:
	


	struct Tile
	{
		int tileIndex;
		bool hasCollision;
		int collisionType;
		RECT collisionRect;
		bool hasEvent;
		string collisionEvent;
		bool hasObject;
		int objectType;
		string objectName;
	};

	struct Layer
	{
		string layerName;
		Tile** tileMap;
		bool visible;
		
		//void SetVisibility(bool isVisible) { visible = isVisible; }
	};
	struct Map
	{
		int tileMapID;
		vector<Layer*> layerList;
		int mapWidth;
		int mapHeight;
		int tileWidth;
		int tileHeight;
		int tileSetWidth;
		int tileSetHeight;

		void Clear();
	};

	Map* map;
	CSGD_TextureManager* m_pTM;
	
	CWorldEngine();
	~CWorldEngine();
	CWorldEngine(const CWorldEngine& copy) {}
	CWorldEngine& operator=(const CWorldEngine& assign) {}


public:
	static CWorldEngine* GetInstance();

	Map* GetMap() { return map; }

	void LoadMap(char* filename);
	void UnLoadMap();
	void DrawMap();
	int CheckCollision(CBase* base);
	bool CheckSolid(CBase* pBase);
};



#endif
